package com.hxx.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hxx.entity.TrainStationEntity;
import com.hxx.service.TrainStationService;
import com.hxx.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/trainStation")
public class TrainStationController {
    @Autowired
    private TrainStationService trainStationService;

    @GetMapping("page")
    public R listPage(Page page, TrainStationEntity trainStation) {
        trainStationService.listPage(page, trainStation);
        return R.ok().data("list", page.getRecords())
                .data("total", page.getTotal());
    }

    @PostMapping("add")
    public R add(TrainStationEntity trainStation) {
        trainStationService.save(trainStation);
        return R.ok();
    }

    @PutMapping("update")
    public R update(TrainStationEntity trainStation) {
        trainStationService.updateById(trainStation);
        return R.ok();
    }

    @DeleteMapping("delete/{id}")
    public R delete(@PathVariable Long id) {
        trainStationService.removeById(id);
        return R.ok();
    }
}






















